//
//  PersonalController.m
//  operativeSide-2.0
//
//  Created by 王春程 on 2016/12/15.
//  Copyright © 2016年 王春程. All rights reserved.
//

#import "PersonalController.h"
#import "PerHeaderView.h"
#import "PerTableView.h"
#import "PerFinViewController.h"
#import "PerProViewController.h"
#import "PerRecViewController.h"
#import "PerTraViewController.h"
#import "PerSetViewController.h"

@interface PersonalController ()<PerTableDelegate>

@property (nonatomic, strong) PerHeaderView *headerView;
@property (nonatomic, strong) PerTableView *perTableView;


@end

@implementation PersonalController

- (void)viewWillAppear:(BOOL)animated {
    [self.navigationController setNavigationBarHidden:YES animated:YES];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = RGB(238, 238, 238);
    self.automaticallyAdjustsScrollViewInsets = YES;
    [self createUI];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


- (void)createUI {
    self.headerView = [[PerHeaderView alloc] initWithFrame:CGRectMake(0, 0, VIEW_WIDTH, 244)];
//    [self.view addSubview:self.headerView];
    
    NSArray *iconArray = @[@"per_fin",@"per_pro",@"per_rec",@"per_tra",@"per_set"];
    NSArray *optinArray = @[@"财 务",@"问 题 单",@"录 单",@"转 运",@"安 全 设 置"];

    
    self.perTableView = [[PerTableView alloc] initWithFrame:CGRectMake(0, -20, VIEW_WIDTH, VIEW_HEIGHT) style:UITableViewStylePlain];
    self.perTableView.tableHeaderView = self.headerView;
    self.perTableView.perTableDelegate = self;
    self.perTableView.iconArray = [NSMutableArray arrayWithArray:iconArray];
    self.perTableView.optionArray  = [NSMutableArray arrayWithArray:optinArray];
    [self.view addSubview:self.perTableView];

}

#pragma mark - PerTableDelegate 
- (void)pushWithRow:(NSUInteger)row {
    switch (row) {
        case 0:
        {
            PerFinViewController *finVC = [[PerFinViewController alloc] init];
            [self.navigationController pushViewController:finVC animated:YES];
        }
            break;
        case 1:
        {
            PerProViewController *proVC = [[PerProViewController alloc] init];
            [self.navigationController pushViewController:proVC animated:YES];
        }
            break;
        case 2:
        {
            PerRecViewController *recVC = [[PerRecViewController alloc] init];
            [self.navigationController pushViewController:recVC animated:YES];
        }
            break;
        case 3:
        {
            PerTraViewController *traVC = [[PerTraViewController alloc] init];
            [self.navigationController pushViewController:traVC animated:YES];
        }
            break;
        case 4:
        {
            PerSetViewController *setVC = [[PerSetViewController alloc] init];
            [self.navigationController pushViewController:setVC animated:YES];
        }
            break;
            
        default:
            break;
    }
}

@end
